﻿@{
    ViewBag.Title = "数据库连接视图";
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/Content/BeginnerAdmin/plugins/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Content/BeginnerAdmin/plugins/layui/layui.js"></script>
    <script src="~/Js/lib/jquery-3.2.1/jquery-3.2.1.js"></script>
</head>
<body>

    选择对应的数据表：<select id="selectId">
        <option>请选择</option>
    </select>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>表的基本信息</legend>
    </fieldset>
    <div class="layui-form">
        <table class="layui-table">
            <colgroup>
                <col width="50">
                <col width="150">
                <col width="150">
                <col width="200">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <th>字段名称</th>
                    <th>字段类型</th>
                    <th>字段大小</th>
                </tr>
            </thead>
            <tbody id="trid"></tbody>

        </table>
    </div>
    <script type="text/javascript">
        $(function () {
            GetProvince();
        });
        function GetProvince() {
            $.getJSON(
                "/DataBaseCon/GetDataTableList",
                function (data) {
                    $.each(data, function (i, item) {
                        $("<option></option>").val(item["FieldName"]).text(item["FieldName"]).appendTo($("#selectId"));
                    });
                });
        }
        $(document).ready(function () {
            $("#selectId").bind("change", function () {
                var value = $(this).val();
                $.ajax({
                    url: "/DataBaseCon/GetDataBaseTableMessage",
                    type: 'post',
                    data: { table: value },
                    dataType: "json",
                    async: "false",
                    success: function (data) {
                        $("#trid").children().remove();
                        $.each(data, function (i, item) {
                            $("#trid").append(
                                "<tr>" +
                                     "<td>" + item.FieldName + "</td>" +
                                     "<td>" + item.FieldType + "</td>" +
                                     "<td>" + item.FieldSize + "</td>" +
                                "</tr>");
                        });

                    }
                });
                //var comment = $('#comment');
                //$.post(
                //"/DataBaseCon/DataBase",
                //{ table: value },
                //function (data) {
                //    comment.load("DataBase.cshtml #comment", null, function () { alert("加载成功") });
                //});
            });
        });
    </script>

</body>
</html>
